#include <iostream>
#include <vector>
#include <string>

int main() {
    std::vector<int> nums = {226, 120, 124, 334, 216, 224, 100, 325, 297, 224};
    std::string ans = "";
    bool wronginput = false;
    std::string wordbuffer = "";
    int sumi = 0;
    std::string a;
    std::getline(std::cin, a);
    int lencount = a.length();
    for (int i = 0; i < a.length(); i++) {
        if (a[i] != ' ' && lencount != 1) {
            wordbuffer += a[i];
        } else {
            if (lencount == 1) {
                wordbuffer += a[i];
            }
            int count = wordbuffer.length();
            for (int f = 0; f < wordbuffer.length(); f++) {
                if (count > 1) {
                    sumi += static_cast<int>(wordbuffer[f]);
                } else {
                    sumi -= static_cast<int>(wordbuffer[f]);
                }
                count--;
            }
            try {
                auto it = std::find(nums.begin(), nums.end(), sumi);
                if (it != nums.end()) {
                    ans += std::to_string(std::distance(nums.begin(), it));
                } else {
                    wronginput = true;
                    break;
                }
            } catch (const std::exception& e) {
                wronginput = true;
                break;
            }
            wordbuffer = "";
            sumi = 0;
        }
        lencount--;
    }
    if (!wronginput) {
        std::cout << std::stoi(ans) - 1 << std::endl;
    } else {
        std::cout << "Wrong input" << std::endl;
    }
    return 0;
}

